﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using PSE.ProcessManager.Common.Process;
using System.Runtime.Serialization;
using PSE.ProcessManager.Entity;

namespace PSE.ProcessManager.Common.Gateway
{
    [ServiceContract(
        Name = "ListenerService",
        Namespace = "http://www.bovespa.com.br/ProcessManager/Listener",
        SessionMode = SessionMode.Required,
        CallbackContract = typeof(IListenerServiceCallback))]
    public interface IListenerService
    {
        [OperationContract(Action = "Connect")]
        void Connect();

        [OperationContract(Action = "ConnectToProcess", ReplyAction = "ConnectToProcessResponse")]
        void ConnectToProcess(int processId, string clientIdentifier);

        [System.ServiceModel.OperationContractAttribute(AsyncPattern = true, Action = "ConnectToProcess", ReplyAction = "ConnectToProcessResponse")]
        System.IAsyncResult BeginConnectToProcess(int processId, string clientIdentifier, System.AsyncCallback callback, object asyncState);

        void EndConnectToProcess(System.IAsyncResult result);

        [OperationContract(Action = "ConnectToListenMessages")]
        void ConnectToListenMessages(List<int> messageIds);

        [OperationContract(Action = "Disconnect")]
        void Disconnect();

        [OperationContract(Action = "SendMessage", ReplyAction = "SendMessageResponse")]
        void SendMessage(System.ServiceModel.Channels.Message message);

        [System.ServiceModel.OperationContractAttribute(AsyncPattern = true, Action = "SendMessage", ReplyAction = "SendMessageResponse")]
        System.IAsyncResult BeginSendMessage(System.ServiceModel.Channels.Message message, System.AsyncCallback callback, object asyncState);

        void EndSendMessage(System.IAsyncResult result);

        [OperationContract(Action = "IsProcessExecuting")]
        bool IsProcessExecuting(int processId);

        [OperationContract(Action = "GetProcessPid")]
        int GetProcessPid(int processId);

        [OperationContract(Action = "RetrieveLogList")]
        List<LogEntity> RetrieveLogList(int processId);

        [OperationContract(Action = "RetrieveLastProcessLog")]
        LogEntity RetrieveLastProcessLog(int processId);

        [OperationContract(Action = "KeepAlive")]
        void KeepAlive();
    }
}
